import Vue from 'vue'

const ResetConstructor = Vue.extend(require('./resetPasswordModal.vue')) // 直接将Vue组件作为Vue.extend的参数

let nId = 1;

let instance;

const ResetModal = (options) => {
    let id = 'lm-' + nId++

    const ResetInstance = new ResetConstructor({
        data: options
    }) // 实例化一个带有content内容的ResetModal

    ResetInstance.id = id
    ResetInstance.vm = ResetInstance.$mount() // 挂载但是并未插入dom，是一个完整的Vue实例
    ResetInstance.vm.visible = true
    ResetInstance.dom = ResetInstance.vm.$el
    document.body.appendChild(ResetInstance.dom) // 将dom插入body
    ResetInstance.dom.style.zIndex = nId + 1001 // 后插入的Notice组件z-index加一，保证能盖在之前的上面

    return ResetInstance
}
ResetModal.show = () => {

    if (instance === undefined){
        instance = ResetModal();
    }

    instance.showModal();
};

export default ResetModal